package org.elip.teststatistics.server.selectors;

import org.apache.commons.vfs2.AllFileSelector;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSelectInfo;

public class TestFileSelector extends AllFileSelector {
	
	@Override
	public boolean includeFile(FileSelectInfo fileInfo) {

		FileObject file = fileInfo.getFile();

		String baseName = file.getName().getBaseName();

		boolean isJava = file.getName().getExtension().equals("class");

		boolean isTest = baseName.contains("Test");

		boolean isAbstract = baseName.contains("Abstract");

		boolean isSingle = !baseName.contains("$");

		return (isJava && isTest && !isAbstract && isSingle);

	}

}
